为了在缩放时修改一个气泡图的范围,应当在PlotElementLoaded (在线文档 'PlotElementLoaded 事件')事件中调整范围,如下所示:
C# |
拷贝代码
|
---|---|
var ds = new BubbleSeries() { XValuesSource = new double[] { 1, 2, 3, 4 }, ValuesSource = new double[] { 1, 2, 3, 4 }, SizeValuesSource = new double[] { 1, 2, 3, 4 }, }; ds.PlotElementLoaded += (s, e) => { var pe = (PlotElement)s; pe.RenderTransform = new ScaleTransform() { ScaleX = 1.0 / chart.View.AxisX.Scale, ScaleY = 1.0 / chart.View.AxisY.Scale }; pe.RenderTransformOrigin = new Point(0.5, 0.5); }; chart.Data.Children.Add(ds); chart.ChartType = ChartType.Bubble; chart.Actions.Add(new TranslateAction()); chart.Actions.Add(new ScaleAction() { Modifiers = ModifierKeys.Control }); |